home *** CD-ROM | disk | FTP | other *** search
- package
- {
- import flash.display.Sprite;
- import flash.events.Event;
- import flash.events.KeyboardEvent;
-
- public class PlayerManager extends Sprite
- {
-
-
- private var §\x01\x01\x02\t§:* = null;
-
- internal const PLAYERINITY:* = 337;
-
- internal const RIGHT:* = 2;
-
- internal const BTATTACK:* = 65;
-
- internal const OUTSCR:* = 999;
-
- private var §\x01\x01\x02\r§:* = null;
-
- internal const LEFT:* = 1;
-
- public var scoreMgr:* = null;
-
- internal const DOC_HEIGHT:* = 400;
-
- internal const LIMITLOWER:* = 337;
-
- internal const PLAYERHEIGHT:* = 85;
-
- internal const JUMP:* = 11;
-
- internal const ATTACK:* = 21;
-
- internal const BTBLOCK:* = 83;
-
- private var §\x01\x01\b\x05§:Boolean;
-
- internal const BTLEFT:* = 37;
-
- internal const PLAYERWIDTH:* = 80;
-
- public var theKnight:* = null;
-
- private var §\x01\x01\x06\r§:* = null;
-
- internal const BLOCK:* = 22;
-
- internal const CENTER:* = 3;
-
- internal const DEAD:* = 666;
-
- internal const DOC_TOP:* = 0;
-
- internal const BTJUMP:* = 38;
-
- private var §\x01\x01\b\x07§:Boolean;
-
- internal const DOWN:* = 12;
-
- internal const STAND:* = 0;
-
- private var §\x01\x01\x04\x0e§:Boolean = false;
-
- internal const BTJUMPATTACK:* = 68;
-
- internal const DOC_WIDTH:* = 640;
-
- internal const PLAYERINITX:* = DOC_WIDTH + 10;
-
- internal const DOC_LEFT:* = 0;
-
- internal const LIMITUPPER:* = 237;
-
- private var §\x01\x01\b\x0b§:int = 0;
-
- private var §\x01\x01\b\r§:int = 0;
-
- internal const NORMAL:* = 20;
-
- internal const BTRIGHT:* = 39;
-
- private var §\x01\x01\b\x0e§:Boolean = false;
-
- private var §\x01\x01\b\x0f§:Boolean;
-
- internal const JUMPATTACK:* = 23;
-
- public function PlayerManager(param1:*, param2:*, param3:*)
- {
- §\x01\x01\x04\x0e§ = false;
- §\x01\x01\x02\t§ = null;
- §\x01\x01\x02\r§ = null;
- scoreMgr = null;
- theKnight = null;
- §\x01\x01\x06\r§ = null;
- §\x01\x01\b\r§ = 0;
- §\x01\x01\b\x0e§ = false;
- §\x01\x01\b\x0b§ = 0;
- super();
- §\x01\x01\x02\t§ = param1;
- §\x01\x01\x02\r§ = param2;
- scoreMgr = param3;
- §\x01\x01\x06\r§ = §\x01\x01\x02\r§.GetSceneContainer();
- }
-
- public function UpdateScore() : *
- {
- scoreMgr.SetHealth(theKnight.Health);
- scoreMgr.SetArmor(theKnight.Armor);
- }
-
- public function GetKnightStatus() : int
- {
- return §\x01\x01\b\r§;
- }
-
- public function SetKnightStatus(param1:String) : *
- {
- if(param1 == "stand" || param1 == "normal")
- {
- §\x01\x01\b\f§(0);
- §\x01\x01\b\r§ = NORMAL;
- theKnight.SetFace("run");
- }
- else if(param1 == "right")
- {
- theKnight.Move("right");
- }
- else if(param1 == "left")
- {
- theKnight.Move("left");
- }
- else if(param1 == "center")
- {
- §\x01\x01\b\r§ = NORMAL;
- theKnight.Move("center");
- if(theKnight.Face != "run")
- {
- theKnight.SetFace("run");
- }
- }
- else if(param1 == "jump")
- {
- if(!§\x01\x01\b\x0e§ && theKnight.Health > 0)
- {
- §\x01\x01\b\f§(700);
- §\x01\x01\b\r§ = JUMP;
- theKnight.Jump();
- if(theKnight.Face != "jump")
- {
- theKnight.SetFace("jump");
- }
- }
- }
- else if(param1 == "jumpattack")
- {
- if(!§\x01\x01\b\x0e§ && theKnight.Armor > 0 && theKnight.Health > 0)
- {
- §\x01\x01\b\f§(700);
- §\x01\x01\b\r§ = JUMPATTACK;
- theKnight.Jump();
- if(theKnight.Face != "jumpattack")
- {
- theKnight.SetFace("jumpattack");
- }
- }
- }
- else if(param1 == "attack")
- {
- if(!§\x01\x01\b\x0e§ && theKnight.Armor > 0 && theKnight.Health > 0)
- {
- §\x01\x01\b\f§(350);
- §\x01\x01\b\r§ = ATTACK;
- if(theKnight.Face != "attack")
- {
- theKnight.SetFace("attack");
- }
- }
- }
- else if(param1 == "block")
- {
- if(!§\x01\x01\b\x0e§ && theKnight.Armor > 0 && theKnight.Health > 0)
- {
- §\x01\x01\b\f§(1);
- §\x01\x01\b\r§ = BLOCK;
- if(theKnight.Face != "block")
- {
- theKnight.SetFace("block");
- }
- }
- }
- else if(param1 == "out")
- {
- §\x01\x01\b\r§ = OUTSCR;
- }
- }
-
- public function StopGame() : *
- {
- §\x01\x01\b\b§();
- §\x01\x01\x02\t§.removeEventListener(KeyboardEvent.KEY_DOWN,§\x01\x01\b\x03§);
- §\x01\x01\x02\t§.removeEventListener(KeyboardEvent.KEY_UP,§\x01\x01\b\x04§);
- §\x01\x01\x02\t§.removeEventListener(Event.ENTER_FRAME,§\x01\x01\b\x06§);
- }
-
- private function §\x01\x01\b\x03§(param1:KeyboardEvent) : *
- {
- if(§\x01\x01\b\r§ != DEAD && §\x01\x01\b\r§ != OUTSCR)
- {
- switch(param1.keyCode)
- {
- case BTRIGHT:
- §\x01\x01\b\x0f§ = true;
- §\x01\x01\b\x07§ = false;
- break;
- case BTLEFT:
- §\x01\x01\b\x07§ = true;
- §\x01\x01\b\x0f§ = false;
- break;
- case BTJUMP:
- if(!§\x01\x01\b\x0e§)
- {
- SetKnightStatus("jump");
- }
- break;
- case BTBLOCK:
- if(!§\x01\x01\b\x0e§)
- {
- §\x01\x01\b\x05§ = true;
- SetKnightStatus("block");
- }
- break;
- case BTATTACK:
- if(!§\x01\x01\b\x0e§)
- {
- SetKnightStatus("attack");
- }
- break;
- case BTJUMPATTACK:
- if(!§\x01\x01\b\x0e§)
- {
- SetKnightStatus("jumpattack");
- }
- }
- }
- }
-
- private function §\x01\x01\b\x04§(param1:KeyboardEvent) : *
- {
- switch(param1.keyCode)
- {
- case BTRIGHT:
- §\x01\x01\b\x0f§ = false;
- break;
- case BTLEFT:
- §\x01\x01\b\x07§ = false;
- break;
- case BTBLOCK:
- §\x01\x01\b\x05§ = false;
- }
- }
-
- private function §\x01\x01\b\x06§(param1:Event) : *
- {
- if(§\x01\x01\b\x0e§)
- {
- §\x01\x01\b\n§();
- }
- if(§\x01\x01\b\x0f§)
- {
- SetKnightStatus("right");
- }
- else if(§\x01\x01\b\x07§)
- {
- SetKnightStatus("left");
- }
- if(!§\x01\x01\b\x05§)
- {
- if(§\x01\x01\b\r§ == BLOCK)
- {
- SetKnightStatus("normal");
- }
- }
- }
-
- public function StartGame() : *
- {
- §\x01\x01\b\t§();
- §\x01\x01\x06\r§.stage.focus = §\x01\x01\x02\t§;
- §\x01\x01\x02\t§.addEventListener(KeyboardEvent.KEY_DOWN,§\x01\x01\b\x03§,false,0,false);
- §\x01\x01\x02\t§.addEventListener(KeyboardEvent.KEY_UP,§\x01\x01\b\x04§,false,0,true);
- §\x01\x01\x02\t§.addEventListener(Event.ENTER_FRAME,§\x01\x01\b\x06§,false,0,true);
- }
-
- private function §\x01\x01\b\b§() : *
- {
- if(theKnight)
- {
- §\x01\x01\x06\r§.removeChild(theKnight);
- theKnight.Destroy();
- theKnight = null;
- }
- }
-
- public function GetKnightHealth() : int
- {
- return theKnight.Health;
- }
-
- public function GetKnightArmor() : int
- {
- return theKnight.Armor;
- }
-
- private function §\x01\x01\b\t§() : *
- {
- §\x01\x01\b\b§();
- theKnight = new knight();
- theKnight.x = PLAYERINITX;
- theKnight.y = PLAYERINITY;
- theKnight.height = PLAYERHEIGHT;
- theKnight.width = PLAYERWIDTH;
- theKnight.Init(§\x01\x01\x02\t§,§\x01\x01\x06\r§,this);
- §\x01\x01\b\x07§ = false;
- §\x01\x01\b\x0f§ = false;
- §\x01\x01\b\x05§ = false;
- §\x01\x01\x06\r§.addChild(theKnight);
- SetKnightStatus("center");
- }
-
- private function §\x01\x01\b\n§() : Boolean
- {
- if(§\x01\x01\b\x0b§ > 0)
- {
- --§\x01\x01\b\x0b§;
- §\x01\x01\b\x0e§ = true;
- }
- else
- {
- SetKnightStatus("normal");
- §\x01\x01\b\x0e§ = false;
- }
- return §\x01\x01\b\x0e§;
- }
-
- private function §\x01\x01\b\f§(param1:*) : *
- {
- if(param1 == 0)
- {
- §\x01\x01\b\x0e§ = false;
- §\x01\x01\b\x0b§ = 0;
- }
- else if(param1 == 1)
- {
- §\x01\x01\b\x0e§ = true;
- §\x01\x01\b\x0b§ = 10000;
- }
- else
- {
- §\x01\x01\b\x0b§ = Math.round(param1 / 42);
- §\x01\x01\b\x0e§ = true;
- }
- }
- }
- }
-